﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DflyingForum.Core.Repositories;

namespace Dottext.Web.UI.Controls
{
    public class Login : BaseControl
    {
        protected TextBox txtUserName;
        protected TextBox txtPassword;
        protected CheckBox chbRemenberMe;
        protected Button btnLogin;

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string password = txtPassword.Text.Trim();
            UserReposity ur = new UserReposity();
            if (ur.IsExistUser(userName, password))
            {
                ur.SetLogCookie(userName, chbRemenberMe.Checked);
                UserReposity.RedirectFromLoginPage(userName, false);
            }
        }

        public override BaseControl ProcessThisControl()
        {
            return this as Login;
        }
    }
}